<?php
namespace  Android\Model;
use Think\Model;

class ArticleModel extends Model
{
    //查询发布文章和动态
       public function mypub(&$user_id){
           $life=D('life');
           //查找粉丝数
           $article = $this->alias('ar')->join('user on ar.user_id=user.user_id')->field("nickname,art_id,ar.time1,title,content,'article' as type")->order('time1 desc')->where('ar.user_id='.$user_id)->select();
           $lifes=$life->field("*,'life' as type")->where('user_id='.$user_id)->select();
           $life_files=M('life_files');
           foreach ($lifes as $k=>$v) {
               $life_id = $v['life_id'];
               $lifes[$k]['files'] = $life_files->field('image,video')->where('life_id=' . $life_id)->select();
           }
           $info=array_merge($article,$lifes);
           foreach ($info as $user) {
               $time[] = $user['time1'];
           }
           array_multisort($time,SORT_DESC,$info);
           return $info;
       }

}